import java.awt.*;
import java.util.Scanner;

public class 第九题 {
    public static int firstCount=0,endCount=0;
    public static char[][] arr1,arr2;
    public static int N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        arr1 = new char[N][N];
        arr2 = new char[N][N];
        sc.nextLine();

        for (int i = 0; i < N; i++) {
            String str = sc.nextLine();
            arr1[i] = str.toCharArray();
            arr2[i] = str.toCharArray();
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (arr1[i][j]=='#'){
                    dfs(i,j);
                    firstCount++;
                }
            }
        }

        for (int x = 0; x < N; x++) {
            for (int y = 0; y < N; y++) {
                if (arr2[x][y]=='#'){
                    dfs2(x,y);
                }
            }
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (arr2[i][j]=='#'){
                    dfs(i,j);
                    endCount++;
                }
            }
        }

        System.out.println(firstCount - endCount);

    }

    private static void dfs2(int x, int y) {
        if((x+1<N)&&(arr2[x+1][y]=='.')) arr2[x][y]='@';
        if((x-1>=0)&&(arr2[x-1][y]=='.')) arr2[x][y]='@';
        if((y+1<N)&&(arr2[x][y+1]=='.')) arr2[x][y]='@';
        if((y-1>=0)&&(arr2[x][y-1]=='.')) arr2[x][y]='@';
    }

    private static void dfs(int x,int y) {
        arr1[x][y] = '.';

        if((x+1<N)&&(arr1[x+1][y]=='#')) dfs(x+1,y);
        if((x-1>=0)&&(arr1[x-1][y]=='#')) dfs(x-1,y);
        if((y+1<N)&&(arr1[x][y+1]=='#')) dfs(x,y+1);
        if((y-1>=0)&&(arr1[x][y-1]=='#')) dfs(x,y-1);
    }
}
